package com.yasaka.stock.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class TWebResult implements Serializable{	
	/**
	 * 
	 */
	private static final long serialVersionUID = 122548766487L;	
	private boolean result;
	private int errCode;
	private String errorInfo;
	private List<?> data;	
	public boolean isResult() {
		return result;
	}
	public void setResult(boolean result) {
		this.result = result;
	}
	public int getErrCode() {
		return errCode;
	}
	public void setErrCode(TApiState aApiState) {
		this.errCode = aApiState.value();
		this.errorInfo =  aApiState.message();
	}
	public String getErrorInfo() {
		return errorInfo;
	}
	public void setErrorInfo(String errorInfo) {
		this.errorInfo = errorInfo;
	}
	public List<?> getData() {
		return data;
	}
	public void setData(List<?> data) {
		this.data = data;
	}
	public TWebResult(){
		
	}
	
	/*
	 * 跟据错误代码生成返回结果
	 */
	public TWebResult(TApiState aApiCode,boolean aResult){
		this.errCode = aApiCode.value();
		this.errorInfo = aApiCode.message();
		this.result = aResult;
		this.data = new ArrayList<String>();
	}
	
	public TWebResult(TApiState aApiCode,String aErrorMsg,boolean aResult){
		this.errCode = aApiCode.value();
		this.errorInfo = aErrorMsg;
		this.result = aResult;
		this.data = new ArrayList<String>();
	}
	
	public TWebResult(int aCustomCode,String aErrorMsg,boolean aResult){
		this.errCode = aCustomCode;
		this.errorInfo = aErrorMsg;
		this.result = aResult;
		this.data = new ArrayList<String>();
	}
	
	public TWebResult(Map<String,Object> aDate){
		this.result = true;
		List<Map<String,Object>> mList = new ArrayList<>();
		mList.add(aDate);
		this.data = mList;		
	}
	
	public TWebResult(List<?> aList){
		this.result = true;
		this.data = aList;		
	}
}
